//
//  LocalViewController.m
//  JJHW_coreData
//
//  Created by lizhenqiang on 16/4/8.
//  Copyright © 2016年 HFKJ_LZQ. All rights reserved.
//

#import "LocalViewController.h"
#import "MBProgressHUD.h"

@interface LocalViewController ()

@end

@implementation LocalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.automaticallyAdjustsScrollViewInsets = NO;//这句代码很重要
    // Do any additional setup after loading the view.
    
    [self setTotalPages:5];
    [self addRefreshHeaderAndFooterView:self.tableView];
    NavBarItem *leftItem = [[NavBarItem alloc] init];
    leftItem.title_normal = @"编辑";
    leftItem.title_selected = @"删除";
    leftItem.type = NavBarItemTypeCanChangeStr;
    leftItem.btnFrame = CGRectMake(DeviceWidth-20, 0, 36, 30);
    [self setRightNavItemWith:leftItem];
}
-(void)viewWillLayoutSubviews
{
//    self.tableView.frame = CGRectMake(0, 0, DeviceWidth, DeviceHeight-64-49);
    if (self.tabBarController) {
        UIEdgeInsets scrollIndicatorInsets = _tableView.scrollIndicatorInsets;
        scrollIndicatorInsets.bottom -= CGRectGetHeight(self.tabBarController.tabBar.bounds);
        _tableView.scrollIndicatorInsets = scrollIndicatorInsets;
    }
}
-(void)loadDataWithCurrentpage:(NSInteger)currentpage
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    for (int i=0; i<10; i++) {
        NSString *str = [NSString stringWithFormat:@"%d",i];
        [self.pageDataArr addObject:str];
    }
    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    [self.tableView reloadData];
    [self.tableView.mj_footer endRefreshing];
    [self.tableView.mj_header endRefreshing];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.pageDataArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"common"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"common"];
    }
    cell.textLabel.text = self.pageDataArr[indexPath.row];
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
